﻿package newpackage;

import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.io.FileUtils;  

/**
 *
 * @author Administrator
 */
public class NewJFrame extends javax.swing.JFrame {
    private int memoryCount;//驻留页面的内存个数
    private int pageCount;//页面总个数
    private int paging[]=null;
    private int memoryTime;//内存存取时间
    private int missInterruptTime;//缺页中断时间
    private int quickTableTime;//访问快表时间
    private Thread FIFOThread;//FIFO线程
    private Thread LRUThread;//LRU线程
    private Thread OPTThread;//OPT线程
    private Thread LFUThread;//LFU线程
    
    //页面初始化
    public NewJFrame() {
        initComponents();
        getParameters();//初始化缺省值
        setLocationRelativeTo(null);//设置窗体居中显示
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    
    //创建窗体
    
    private void initComponents() {

        jFileChooser1 = new javax.swing.JFileChooser();
        jDialog1 = new javax.swing.JDialog();
        jPanel6 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jDialog2 = new javax.swing.JDialog();
        jLabel25 = new javax.swing.JLabel();
        ok1jButton = new javax.swing.JButton();
        jDialog3 = new javax.swing.JDialog();
        jLabel26 = new javax.swing.JLabel();
        ok2jButton1 = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        showjPanel = new javax.swing.JPanel();
        FIFOjPanel = new javax.swing.JPanel();
        FIFOjScrollPane = new javax.swing.JScrollPane();
        FIFOjTextArea = new javax.swing.JTextArea();
        startjButton = new javax.swing.JButton();
        suspendjButton = new javax.swing.JButton();
        resumejButton = new javax.swing.JButton();
        stopjButton = new javax.swing.JButton();
        clearjButton = new javax.swing.JButton();
        savejButton = new javax.swing.JButton();
        LRUjPanel = new javax.swing.JPanel();
        LRUjScrollPane = new javax.swing.JScrollPane();
        LRUjTextArea = new javax.swing.JTextArea();
        OPTjPanel = new javax.swing.JPanel();
        OPTjScrollPane = new javax.swing.JScrollPane();
        OPTjTextArea = new javax.swing.JTextArea();
        LFUjPanel = new javax.swing.JPanel();
        LFUjScrollPane = new javax.swing.JScrollPane();
        LFUjTextArea = new javax.swing.JTextArea();
        resultjPanel = new javax.swing.JPanel();
        jLabel38 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        FIFOmissnumberjLabel = new javax.swing.JLabel();
        LRUmissnumberjLabel = new javax.swing.JLabel();
        OPTmissnumberjLabel = new javax.swing.JLabel();
        LFUmissnumberjLabel = new javax.swing.JLabel();
        FIFOmissratejLabel = new javax.swing.JLabel();
        LRUmissratejLabel = new javax.swing.JLabel();
        OPTmissratejLabel = new javax.swing.JLabel();
        LFUmissratejLabel = new javax.swing.JLabel();
        FIFOallmemorytimejLabel = new javax.swing.JLabel();
        LRUallmemorytimejLabel = new javax.swing.JLabel();
        OPTallmemorytimejLabel = new javax.swing.JLabel();
        LFUallmemorytimejLabel = new javax.swing.JLabel();
        setParameterjPanel = new javax.swing.JPanel();
        pagequeuejPanel = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        pagingjTextField = new javax.swing.JTextField();
        RandomjButton = new javax.swing.JButton();
        basicjPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        memoryCountjTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        pageCountjTextField = new javax.swing.JTextField();
        maxPageNumberjSpinner = new javax.swing.JSpinner();
        jLabel3 = new javax.swing.JLabel();
        minPageNumberjSpinner = new javax.swing.JSpinner();
        jLabel4 = new javax.swing.JLabel();
        timejPanel = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        memoryTimejTextField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        missInterruptTimejTextField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        quickTableTimejTextField = new javax.swing.JTextField();
        hasQuickTablejCheckBox = new javax.swing.JCheckBox();
        jLabel28 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        ResetjButton = new javax.swing.JButton();
        surejButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        jFileChooser1.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
        jFileChooser1.setCurrentDirectory(new java.io.File("D:\\360Downloads\\0DeskTop\\subjectmatter\\OS课设\\java\\pageReplace\\data"));
        jFileChooser1.setDialogTitle("保存数据");
        jFileChooser1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)));

        jDialog1.setTitle("帮助手册");
        jDialog1.setBounds(new java.awt.Rectangle(0, 0, 500, 300));
        jDialog1.setModal(true);

        jLabel13.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel13.setText("1.请先进行参数设置才能开始运行。");

        jLabel14.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel14.setText("2.如果不进行参数设置，内存数默认值为3，");

        jLabel15.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel15.setText("3.如果时间项不进行设置，");

        jLabel16.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel16.setText("4.保存数据的默认格式为.txt文件。");

        jLabel18.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel18.setText("页面总个数默认为20，页号范围默认是0到9之间。");

        jLabel19.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel19.setText("则默认在输出框中只输出驻留内存序列号。");

        jLabel20.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel20.setText("5.参数配置完成后，请先点击确定按钮，再运行程序。");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 411, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel19)
                            .addComponent(jLabel18)))
                    .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 411, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel18)
                .addGap(18, 18, 18)
                .addComponent(jLabel15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel19)
                .addGap(18, 18, 18)
                .addComponent(jLabel16)
                .addGap(18, 18, 18)
                .addComponent(jLabel20)
                .addContainerGap(59, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jDialog2.setTitle("提示");
        jDialog2.setBackground(new java.awt.Color(204, 204, 204));
        jDialog2.setBounds(new java.awt.Rectangle(0, 0, 400, 300));
        jDialog2.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jDialog2.setLocation(new java.awt.Point(0, 0));
        jDialog2.setModal(true);
        jDialog2.setSize(new java.awt.Dimension(400, 300));
        jDialog2.setType(java.awt.Window.Type.POPUP);

        jLabel25.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel25.setForeground(new java.awt.Color(255, 0, 0));
        jLabel25.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel25.setText("请输入数字！");

        ok1jButton.setBackground(new java.awt.Color(0, 102, 255));
        ok1jButton.setFont(new java.awt.Font("宋体", 1, 14)); // NOI18N
        ok1jButton.setForeground(new java.awt.Color(255, 255, 255));
        ok1jButton.setText("确定");
        ok1jButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        ok1jButton.setFocusPainted(false);
        ok1jButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ok1jButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialog2Layout = new javax.swing.GroupLayout(jDialog2.getContentPane());
        jDialog2.getContentPane().setLayout(jDialog2Layout);
        jDialog2Layout.setHorizontalGroup(
            jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(ok1jButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(44, 44, 44))
            .addGroup(jDialog2Layout.createSequentialGroup()
                .addGap(97, 97, 97)
                .addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(103, Short.MAX_VALUE))
        );
        jDialog2Layout.setVerticalGroup(
            jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog2Layout.createSequentialGroup()
                .addContainerGap(89, Short.MAX_VALUE)
                .addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45)
                .addComponent(ok1jButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41))
        );

        jDialog3.setTitle("提示");
        jDialog3.setModal(true);
        jDialog3.setSize(new java.awt.Dimension(400, 300));
        jDialog3.setType(java.awt.Window.Type.POPUP);

        jLabel26.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel26.setForeground(new java.awt.Color(255, 0, 0));
        jLabel26.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel26.setText("入值不一致！");

        ok2jButton1.setBackground(new java.awt.Color(0, 102, 255));
        ok2jButton1.setFont(new java.awt.Font("宋体", 1, 14)); // NOI18N
        ok2jButton1.setForeground(new java.awt.Color(255, 255, 255));
        ok2jButton1.setText("确定");
        ok2jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        ok2jButton1.setFocusPainted(false);
        ok2jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ok2jButton1ActionPerformed(evt);
            }
        });

        jLabel27.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel27.setForeground(new java.awt.Color(255, 0, 0));
        jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel27.setText("页面总个数输入值与页面序列个数实际输");

        javax.swing.GroupLayout jDialog3Layout = new javax.swing.GroupLayout(jDialog3.getContentPane());
        jDialog3.getContentPane().setLayout(jDialog3Layout);
        jDialog3Layout.setHorizontalGroup(
            jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog3Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 19, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(ok2jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39))
        );
        jDialog3Layout.setVerticalGroup(
            jDialog3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog3Layout.createSequentialGroup()
                .addContainerGap(81, Short.MAX_VALUE)
                .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(48, 48, 48)
                .addComponent(ok2jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(49, 49, 49))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("模拟页面置换算法");
        setBounds(new java.awt.Rectangle(0, 0, 590, 854));
        setSize(new java.awt.Dimension(400, 300));
        setType(java.awt.Window.Type.POPUP);

        jTabbedPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jTabbedPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTabbedPane1.setFont(new java.awt.Font("宋体", 0, 18)); // NOI18N

        showjPanel.setBackground(new java.awt.Color(255, 255, 255));

        FIFOjPanel.setBackground(new java.awt.Color(250, 250, 250));
        FIFOjPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "FIFO", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 16), new java.awt.Color(0, 102, 255))); // NOI18N

        FIFOjTextArea.setColumns(20);
        FIFOjTextArea.setFont(new java.awt.Font("宋体", 1, 13)); // NOI18N
        FIFOjTextArea.setRows(5);
        FIFOjScrollPane.setViewportView(FIFOjTextArea);

        javax.swing.GroupLayout FIFOjPanelLayout = new javax.swing.GroupLayout(FIFOjPanel);
        FIFOjPanel.setLayout(FIFOjPanelLayout);
        FIFOjPanelLayout.setHorizontalGroup(
            FIFOjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(FIFOjScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
        );
        FIFOjPanelLayout.setVerticalGroup(
            FIFOjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(FIFOjScrollPane, javax.swing.GroupLayout.Alignment.TRAILING)
        );

        startjButton.setBackground(new java.awt.Color(0, 102, 255));
        startjButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        startjButton.setForeground(new java.awt.Color(255, 255, 255));
        startjButton.setText("开始");
        startjButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        startjButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        startjButton.setEnabled(false);
        startjButton.setFocusPainted(false);
        startjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startjButtonActionPerformed(evt);
            }
        });

        suspendjButton.setBackground(new java.awt.Color(0, 102, 255));
        suspendjButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        suspendjButton.setForeground(new java.awt.Color(255, 255, 255));
        suspendjButton.setText("暂停");
        suspendjButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        suspendjButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        suspendjButton.setEnabled(false);
        suspendjButton.setFocusPainted(false);
        suspendjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                suspendjButtonActionPerformed(evt);
            }
        });

        resumejButton.setBackground(new java.awt.Color(0, 102, 255));
        resumejButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        resumejButton.setForeground(new java.awt.Color(255, 255, 255));
        resumejButton.setText("继续");
        resumejButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        resumejButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        resumejButton.setEnabled(false);
        resumejButton.setFocusPainted(false);
        resumejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resumejButtonActionPerformed(evt);
            }
        });

        stopjButton.setBackground(new java.awt.Color(0, 102, 255));
        stopjButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        stopjButton.setForeground(new java.awt.Color(255, 255, 255));
        stopjButton.setText("停止");
        stopjButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        stopjButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        stopjButton.setEnabled(false);
        stopjButton.setFocusPainted(false);
        stopjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopjButtonActionPerformed(evt);
            }
        });

        clearjButton.setBackground(new java.awt.Color(0, 102, 255));
        clearjButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        clearjButton.setForeground(new java.awt.Color(255, 255, 255));
        clearjButton.setText("清空");
        clearjButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        clearjButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        clearjButton.setEnabled(false);
        clearjButton.setFocusPainted(false);
        clearjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearjButtonjButton5ActionPerformed(evt);
            }
        });

        savejButton.setBackground(new java.awt.Color(0, 102, 255));
        savejButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        savejButton.setForeground(new java.awt.Color(255, 255, 255));
        savejButton.setText("保存数据");
        savejButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        savejButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        savejButton.setEnabled(false);
        savejButton.setFocusPainted(false);
        savejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                savejButtonActionPerformed(evt);
            }
        });

        LRUjPanel.setBackground(new java.awt.Color(250, 250, 250));
        LRUjPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "LRU", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 16), new java.awt.Color(0, 102, 255))); // NOI18N

        LRUjTextArea.setColumns(20);
        LRUjTextArea.setFont(new java.awt.Font("宋体", 1, 13)); // NOI18N
        LRUjTextArea.setRows(5);
        LRUjScrollPane.setViewportView(LRUjTextArea);

        javax.swing.GroupLayout LRUjPanelLayout = new javax.swing.GroupLayout(LRUjPanel);
        LRUjPanel.setLayout(LRUjPanelLayout);
        LRUjPanelLayout.setHorizontalGroup(
            LRUjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(LRUjScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
        );
        LRUjPanelLayout.setVerticalGroup(
            LRUjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(LRUjScrollPane, javax.swing.GroupLayout.Alignment.TRAILING)
        );

        OPTjPanel.setBackground(new java.awt.Color(250, 250, 250));
        OPTjPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "OPT", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 16), new java.awt.Color(0, 102, 255))); // NOI18N

        OPTjTextArea.setColumns(20);
        OPTjTextArea.setFont(new java.awt.Font("宋体", 1, 13)); // NOI18N
        OPTjTextArea.setRows(5);
        OPTjScrollPane.setViewportView(OPTjTextArea);

        javax.swing.GroupLayout OPTjPanelLayout = new javax.swing.GroupLayout(OPTjPanel);
        OPTjPanel.setLayout(OPTjPanelLayout);
        OPTjPanelLayout.setHorizontalGroup(
            OPTjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OPTjScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
        );
        OPTjPanelLayout.setVerticalGroup(
            OPTjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(OPTjScrollPane, javax.swing.GroupLayout.Alignment.TRAILING)
        );

        LFUjPanel.setBackground(new java.awt.Color(250, 250, 250));
        LFUjPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "LFU", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 16), new java.awt.Color(0, 102, 255))); // NOI18N

        LFUjTextArea.setColumns(20);
        LFUjTextArea.setFont(new java.awt.Font("宋体", 1, 13)); // NOI18N
        LFUjTextArea.setRows(5);
        LFUjScrollPane.setViewportView(LFUjTextArea);

        javax.swing.GroupLayout LFUjPanelLayout = new javax.swing.GroupLayout(LFUjPanel);
        LFUjPanel.setLayout(LFUjPanelLayout);
        LFUjPanelLayout.setHorizontalGroup(
            LFUjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(LFUjScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
        );
        LFUjPanelLayout.setVerticalGroup(
            LFUjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(LFUjScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
        );

        resultjPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "模拟结果", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 16), new java.awt.Color(0, 102, 255))); // NOI18N

        jLabel38.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel38.setText("缺页中断次数：");

        jLabel42.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel42.setText("OPT");

        jLabel39.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel39.setText("FIFO");

        jLabel40.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel40.setText("LRU");

        jLabel41.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel41.setText("LFU");

        jLabel21.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel21.setText("缺页率：");

        jLabel17.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel17.setText("内存总存取时间：");

        FIFOmissnumberjLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        FIFOmissnumberjLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        FIFOmissnumberjLabel.setText("0");

        LRUmissnumberjLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        LRUmissnumberjLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LRUmissnumberjLabel.setText("0");

        OPTmissnumberjLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        OPTmissnumberjLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        OPTmissnumberjLabel.setText("0");

        LFUmissnumberjLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        LFUmissnumberjLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LFUmissnumberjLabel.setText("0");

        FIFOmissratejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        FIFOmissratejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        FIFOmissratejLabel.setText("0");

        LRUmissratejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        LRUmissratejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LRUmissratejLabel.setText("0");

        OPTmissratejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        OPTmissratejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        OPTmissratejLabel.setText("0");

        LFUmissratejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        LFUmissratejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LFUmissratejLabel.setText("0");

        FIFOallmemorytimejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        FIFOallmemorytimejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        FIFOallmemorytimejLabel.setText("0");

        LRUallmemorytimejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        LRUallmemorytimejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LRUallmemorytimejLabel.setText("0");

        OPTallmemorytimejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        OPTallmemorytimejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        OPTallmemorytimejLabel.setText("0");

        LFUallmemorytimejLabel.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        LFUallmemorytimejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LFUallmemorytimejLabel.setText("0");

        javax.swing.GroupLayout resultjPanelLayout = new javax.swing.GroupLayout(resultjPanel);
        resultjPanel.setLayout(resultjPanelLayout);
        resultjPanelLayout.setHorizontalGroup(
            resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(resultjPanelLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(resultjPanelLayout.createSequentialGroup()
                        .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel21)
                            .addComponent(jLabel38)
                            .addComponent(jLabel17))
                        .addGap(30, 30, 30)
                        .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(FIFOmissnumberjLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(FIFOmissratejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(FIFOallmemorytimejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, resultjPanelLayout.createSequentialGroup()
                        .addComponent(jLabel39)
                        .addGap(17, 17, 17)))
                .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(resultjPanelLayout.createSequentialGroup()
                        .addGap(111, 111, 111)
                        .addComponent(jLabel40)
                        .addGap(130, 130, 130)
                        .addComponent(jLabel42)
                        .addGap(130, 130, 130)
                        .addComponent(jLabel41))
                    .addGroup(resultjPanelLayout.createSequentialGroup()
                        .addGap(93, 93, 93)
                        .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LRUmissnumberjLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(LRUmissratejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(LRUallmemorytimejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(94, 94, 94)
                        .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(OPTmissnumberjLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(OPTmissratejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(OPTallmemorytimejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(95, 95, 95)
                        .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LFUallmemorytimejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(LFUmissratejLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(LFUmissnumberjLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        resultjPanelLayout.setVerticalGroup(
            resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(resultjPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel42)
                    .addComponent(jLabel39)
                    .addComponent(jLabel40)
                    .addComponent(jLabel41))
                .addGap(18, 18, 18)
                .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel38)
                    .addComponent(FIFOmissnumberjLabel)
                    .addComponent(LRUmissnumberjLabel)
                    .addComponent(OPTmissnumberjLabel)
                    .addComponent(LFUmissnumberjLabel))
                .addGap(26, 26, 26)
                .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(FIFOmissratejLabel)
                    .addComponent(LRUmissratejLabel)
                    .addComponent(OPTmissratejLabel)
                    .addComponent(LFUmissratejLabel))
                .addGap(24, 24, 24)
                .addGroup(resultjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(FIFOallmemorytimejLabel)
                    .addComponent(LRUallmemorytimejLabel)
                    .addComponent(OPTallmemorytimejLabel)
                    .addComponent(LFUallmemorytimejLabel))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout showjPanelLayout = new javax.swing.GroupLayout(showjPanel);
        showjPanel.setLayout(showjPanelLayout);
        showjPanelLayout.setHorizontalGroup(
            showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(showjPanelLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(showjPanelLayout.createSequentialGroup()
                        .addComponent(FIFOjPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(LRUjPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(OPTjPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(resultjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                .addGroup(showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(stopjButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, showjPanelLayout.createSequentialGroup()
                        .addComponent(clearjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(savejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(startjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LFUjPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(showjPanelLayout.createSequentialGroup()
                        .addComponent(suspendjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(resumejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(30, 30, 30))
        );
        showjPanelLayout.setVerticalGroup(
            showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(showjPanelLayout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(LFUjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(OPTjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(LRUjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(FIFOjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(30, 30, 30)
                .addGroup(showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(resultjPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(showjPanelLayout.createSequentialGroup()
                        .addGroup(showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(startjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(stopjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(29, 29, 29)
                        .addGroup(showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(suspendjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(resumejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(showjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(clearjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(savejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(30, 30, 30))
        );

        jTabbedPane1.addTab("模拟过程演示", showjPanel);

        setParameterjPanel.setBackground(new java.awt.Color(255, 255, 255));

        pagequeuejPanel.setBackground(new java.awt.Color(250, 250, 250));
        pagequeuejPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "页号序列", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 18), new java.awt.Color(0, 102, 255))); // NOI18N
        pagequeuejPanel.setFont(new java.awt.Font("宋体", 1, 14)); // NOI18N

        jLabel5.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel5.setText("页号序列：");

        pagingjTextField.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        pagingjTextField.setText("7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1");
        pagingjTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        RandomjButton.setBackground(new java.awt.Color(0, 102, 255));
        RandomjButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        RandomjButton.setForeground(new java.awt.Color(255, 255, 255));
        RandomjButton.setText("随机生成");
        RandomjButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        RandomjButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        RandomjButton.setFocusPainted(false);
        RandomjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        RandomjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RandomjButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pagequeuejPanelLayout = new javax.swing.GroupLayout(pagequeuejPanel);
        pagequeuejPanel.setLayout(pagequeuejPanelLayout);
        pagequeuejPanelLayout.setHorizontalGroup(
            pagequeuejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pagequeuejPanelLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(pagingjTextField)
                .addGap(100, 100, 100)
                .addComponent(RandomjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53))
        );
        pagequeuejPanelLayout.setVerticalGroup(
            pagequeuejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pagequeuejPanelLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(pagequeuejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(pagingjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(RandomjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 34, Short.MAX_VALUE))
        );

        basicjPanel.setBackground(new java.awt.Color(250, 250, 250));
        basicjPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "基本设置", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 18), new java.awt.Color(0, 102, 255))); // NOI18N
        basicjPanel.setPreferredSize(new java.awt.Dimension(400, 150));

        jLabel1.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel1.setText("驻留内存页面的个数：");
        jLabel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        memoryCountjTextField.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        memoryCountjTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        memoryCountjTextField.setText("3");
        memoryCountjTextField.setToolTipText("请输入数字");
        memoryCountjTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
        memoryCountjTextField.setSelectionColor(new java.awt.Color(0, 102, 255));

        jLabel2.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel2.setText("页面总个数：");

        pageCountjTextField.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        pageCountjTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        pageCountjTextField.setText("20");
        pageCountjTextField.setToolTipText("请输入数字");
        pageCountjTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
        pageCountjTextField.setSelectionColor(new java.awt.Color(0, 102, 255));

        maxPageNumberjSpinner.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        maxPageNumberjSpinner.setModel(new javax.swing.SpinnerNumberModel(9, null, null, 1));
        maxPageNumberjSpinner.setToolTipText("最大值");
        maxPageNumberjSpinner.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
        maxPageNumberjSpinner.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        maxPageNumberjSpinner.setEditor(new javax.swing.JSpinner.NumberEditor(maxPageNumberjSpinner, ""));

        jLabel3.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel3.setText("页号范围：");

        minPageNumberjSpinner.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        minPageNumberjSpinner.setModel(new javax.swing.SpinnerNumberModel());
        minPageNumberjSpinner.setToolTipText("最小值");
        minPageNumberjSpinner.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
        minPageNumberjSpinner.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        minPageNumberjSpinner.setEditor(new javax.swing.JSpinner.NumberEditor(minPageNumberjSpinner, ""));
        minPageNumberjSpinner.setFocusable(false);
        minPageNumberjSpinner.setVerifyInputWhenFocusTarget(false);

        jLabel4.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel4.setText("~");

        javax.swing.GroupLayout basicjPanelLayout = new javax.swing.GroupLayout(basicjPanel);
        basicjPanel.setLayout(basicjPanelLayout);
        basicjPanelLayout.setHorizontalGroup(
            basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(basicjPanelLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pageCountjTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                    .addComponent(memoryCountjTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                    .addGroup(basicjPanelLayout.createSequentialGroup()
                        .addComponent(minPageNumberjSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(13, 13, 13)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                        .addComponent(maxPageNumberjSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(187, Short.MAX_VALUE))
        );
        basicjPanelLayout.setVerticalGroup(
            basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(basicjPanelLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(memoryCountjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pageCountjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGroup(basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(basicjPanelLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(basicjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(minPageNumberjSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(maxPageNumberjSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(basicjPanelLayout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(jLabel4)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        timejPanel.setBackground(new java.awt.Color(250, 250, 250));
        timejPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 255)), "时间设置", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("宋体", 1, 18), new java.awt.Color(0, 102, 255))); // NOI18N
        timejPanel.setPreferredSize(new java.awt.Dimension(400, 150));

        jLabel6.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel6.setText("内存的存取时间：");

        memoryTimejTextField.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        memoryTimejTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        memoryTimejTextField.setText("8");
        memoryTimejTextField.setToolTipText("请输入数字");
        memoryTimejTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jLabel7.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel7.setText("缺页中断的时间：");

        missInterruptTimejTextField.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        missInterruptTimejTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        missInterruptTimejTextField.setText("20");
        missInterruptTimejTextField.setToolTipText("请输入数字");
        missInterruptTimejTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jLabel8.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel8.setText("访问快表的时间：");

        quickTableTimejTextField.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        quickTableTimejTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        quickTableTimejTextField.setText("1");
        quickTableTimejTextField.setToolTipText("请输入数字");
        quickTableTimejTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        hasQuickTablejCheckBox.setBackground(new java.awt.Color(250, 250, 250));
        hasQuickTablejCheckBox.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        hasQuickTablejCheckBox.setForeground(new java.awt.Color(0, 102, 255));
        hasQuickTablejCheckBox.setSelected(true);
        hasQuickTablejCheckBox.setText("启用快表");
        hasQuickTablejCheckBox.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        hasQuickTablejCheckBox.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        hasQuickTablejCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hasQuickTablejCheckBoxActionPerformed(evt);
            }
        });

        jLabel28.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        jLabel28.setText("是否使用快表：");

        jLabel30.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel30.setText("us");

        jLabel31.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel31.setText("us");

        jLabel32.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel32.setText("us");

        javax.swing.GroupLayout timejPanelLayout = new javax.swing.GroupLayout(timejPanel);
        timejPanel.setLayout(timejPanelLayout);
        timejPanelLayout.setHorizontalGroup(
            timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(timejPanelLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel6)
                        .addComponent(jLabel7))
                    .addComponent(jLabel8)
                    .addComponent(jLabel28, javax.swing.GroupLayout.Alignment.LEADING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(missInterruptTimejTextField)
                    .addComponent(memoryTimejTextField)
                    .addComponent(quickTableTimejTextField)
                    .addComponent(hasQuickTablejCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel30)
                    .addComponent(jLabel31)
                    .addComponent(jLabel32))
                .addContainerGap(198, Short.MAX_VALUE))
        );
        timejPanelLayout.setVerticalGroup(
            timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(timejPanelLayout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(memoryTimejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel30))
                .addGap(18, 18, 18)
                .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(missInterruptTimejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel31))
                .addGap(18, 18, 18)
                .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(hasQuickTablejCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel28))
                .addGap(18, 18, 18)
                .addGroup(timejPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(quickTableTimejTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel32))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        ResetjButton.setBackground(new java.awt.Color(0, 102, 255));
        ResetjButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        ResetjButton.setForeground(new java.awt.Color(255, 255, 255));
        ResetjButton.setText("恢复默认值");
        ResetjButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        ResetjButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        ResetjButton.setFocusPainted(false);
        ResetjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        ResetjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetjButtonActionPerformed(evt);
            }
        });

        surejButton.setBackground(new java.awt.Color(0, 102, 255));
        surejButton.setFont(new java.awt.Font("宋体", 1, 16)); // NOI18N
        surejButton.setForeground(new java.awt.Color(255, 255, 255));
        surejButton.setText("确定");
        surejButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        surejButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        surejButton.setFocusPainted(false);
        surejButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        surejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                surejButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout setParameterjPanelLayout = new javax.swing.GroupLayout(setParameterjPanel);
        setParameterjPanel.setLayout(setParameterjPanelLayout);
        setParameterjPanelLayout.setHorizontalGroup(
            setParameterjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, setParameterjPanelLayout.createSequentialGroup()
                .addGroup(setParameterjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(setParameterjPanelLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(surejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(51, 51, 51)
                        .addComponent(ResetjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(setParameterjPanelLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(setParameterjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(pagequeuejPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(setParameterjPanelLayout.createSequentialGroup()
                                .addComponent(basicjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE)
                                .addGap(35, 35, 35)
                                .addComponent(timejPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)))))
                .addGap(30, 30, 30))
        );
        setParameterjPanelLayout.setVerticalGroup(
            setParameterjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, setParameterjPanelLayout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(setParameterjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(timejPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                    .addComponent(basicjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE))
                .addGap(40, 40, 40)
                .addComponent(pagequeuejPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30)
                .addGroup(setParameterjPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(surejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ResetjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30))
        );

        jTabbedPane1.addTab("参数设置", setParameterjPanel);

        jMenuBar1.setBackground(new java.awt.Color(204, 204, 204));
        jMenuBar1.setBorder(null);
        jMenuBar1.setBorderPainted(false);
        jMenuBar1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jMenuBar1.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N

        jMenu1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jMenu1.setText("模拟页面置换算法");
        jMenu1.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jMenuBar1.add(jMenu1);

        jMenu2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jMenu2.setText("帮助");
        jMenu2.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N

        jMenuItem2.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jMenuItem2.setText("帮助手册");
        jMenuItem2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jMenuItem2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 644, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    
    
    /* -----------------------------------END------------------------------------------------*/
    
    
    
    /**
     * 四个页面置换算法均采用实现Runnable接口，但是它并没有start方法，因此它的启动还需要一个Thread实例。
     */
    
    ////////////////////////////////start/////////////
    
    
    
 
    //FIFO算法
    class FIFO implements Runnable{
        int p[],m,time=0,allTime=0;
        public synchronized void run(){
            Queue<Integer> queue = new LinkedList<Integer>();  //integer类型的列表 queue
            Map<Integer,Integer>map=new HashMap<Integer,Integer>();//存储每一个内储页框所存的内容 
            List<Integer>list=new ArrayList<Integer>();//存储页面序列
            Queue<Integer> quick = new LinkedList<Integer>();  //快表队列，快表均采用先进先出的置换方式. 空列表quick
            p=paging;     
            m=memoryCount;
            
            String s = "";
          
            int q=0;
            int j=0;
            for (int i=0;i<p.length;i++){     //p.length=20
	    	list.add(p[i]);
            }
            for (int i=0;i<p.length;i++){
	      	int k=list.get(i);//从list取出每一个页号
	    	if (!map.containsValue(k)){          //如果不在里面
                    q++;//不能直接找到次数加1
                    if(hasQuickTablejCheckBox.isSelected()&&i<3){
                        quick.offer(k);     //元素加入快表队列,并设长度为3
             
                    }
                    if (map.size()<m){//如果没有装满
	    		int temp=map.size();    
	    		map.put(temp, k);		//map(0,7) map(1,0) map(2,1)
	    
	    		queue.offer(k);	//将页号送入队列
                    }
                    else{   //内存已满
                        int temp=0;
                     
	    		int t=queue.poll();//元素出队
	    		for(Map.Entry<Integer, Integer> entry:map.entrySet()){    
                            if (entry.getValue()==t) {    //将要删除页号的key赋给t，以便在map中同时替换
                                temp=entry.getKey();
                      
                          
                                break;
                            } 
                        }
                        map.remove(temp);//更新内存块
                        map.put(temp,k);
	    	        queue.offer(k);//将页号送入队列
	    	    }
//                  
////                    for(Map.Entry<Integer, Integer> entry:map.entrySet()){   //改：
////                    	int h=entry.getValue();
////                        s = s + h;
////                    }
                    if(hasQuickTablejCheckBox.isSelected()){  //如果选择快表模式
                        time = quickTableTime+memoryTime+missInterruptTime+memoryTime;
                        allTime = allTime +time;
                    }else{
                        time = memoryTime+missInterruptTime+memoryTime;//如果没有选择快表模式
                        allTime = allTime +time;
                    }
                    try {
                        if(memoryTime!=-1&&missInterruptTime!=-1){
                            FIFOjTextArea.append("内存页号：" + s + "；" + "时间：" + time + "us；缺页\r\n");
                            FIFOjTextArea.setCaretPosition(FIFOjTextArea.getText().length());//滚动条滚动
                        }else{
                            FIFOjTextArea.append("内存页号：" + s + "；缺页\r\n");
                            FIFOjTextArea.setCaretPosition(FIFOjTextArea.getText().length());//滚动条滚动
                        }
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    s="";
	    	}
            else{//在内存
              
	    		 for(Map.Entry<Integer, Integer> entry:map.entrySet()){   //改：
                 	int h=entry.getValue();
	        	     s= s + h;
                    }
                    if(hasQuickTablejCheckBox.isSelected()){
                        for(Integer x:quick){
                            if(k==x){
                                time = quickTableTime+memoryTime;
                                allTime = allTime +time;
                                System.out.println("在快表命中");
                                break;
                            }else{
                                time = quickTableTime+memoryTime+memoryTime;
                                allTime = allTime +time;
                                quick.poll();    //如果没在快表中，先进先出更新快表
                                quick.offer(k);
                                break;
                            }
                        }
                    }else{
                        time=memoryTime+memoryTime;
                        allTime = allTime +time;
                    }
                    try {
                        if(memoryTime!=-1&&missInterruptTime!=-1){
                            FIFOjTextArea.append("内存页号：" + s  + "；" + "时间：" + time + "us；不缺页\r\n");
                            FIFOjTextArea.setCaretPosition(FIFOjTextArea.getText().length());//滚动条滚动
                        }else{
                            FIFOjTextArea.append("内存页号：" + s + "；缺页\r\n");
                            FIFOjTextArea.setCaretPosition(FIFOjTextArea.getText().length());//滚动条滚动
                        }
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    s="";
                    time=0;
	    	}
	    }
            NumberFormat formatter = new DecimalFormat("0.0");//设置缺页率
            Double x=new Double((double)q/(double)p.length);
            String xx = formatter.format(x*100);
            FIFOmissnumberjLabel.setText(q+"");
            FIFOmissratejLabel.setText(xx+"%");
            FIFOallmemorytimejLabel.setText(allTime+"us");
            startjButton.setEnabled(true);
            stopjButton.setEnabled(false);
            resumejButton.setEnabled(false);
            suspendjButton.setEnabled(false);
        }
    }
    
   
    //OPT算法
    class OPT implements Runnable{
        int p[],m,q=0,w=0,time=0,allTime = 0;
        public synchronized void run(){
            Map<Integer,Integer>map=new HashMap<Integer,Integer>();
            List<Integer>list=new ArrayList<Integer>();
            Queue<Integer> quick = new LinkedList<Integer>();
            String s = "";
            p=paging;
            m=memoryCount;
            boolean flag=false;
            for (int i=0;i<p.length;i++){    //p.length=20
                list.add(p[i]);
            }
            int j=0;
            for (int i=0;i<p.length;i++){
                int k=list.get(i);//从list取出每一个页号
                if (!map.containsValue(k)){    //如果不在
                    q++;//不能直接找到次数加1
                    if(hasQuickTablejCheckBox.isSelected()&&i<3){
                        quick.offer(k);     //初始元素加入快表队列,并设长度为3
                    }
                    if (map.size()<m){//如果没有装满
                        int temp=map.size();
                        map.put(temp, k);
                    }else{//如果装满了
                        int index=0;//把哪个位置的淘汰出去
                        int max=0;//初始最长长度
                        for (int t=0;t<m;t++){
                            for (j=i+1;j<p.length;j++){//看后面哪一个出现的最晚
                                if (list.get(j)==map.get(t)){//第一次找到
                                    if (j-i>max){
                                        index=t;//更新值
                                        max=j-i;
                                    }
                                    flag=true;//设置标识，否则如果内存中有的元素没有在后续出现，而有的出现，会出现错误
                                    break;
                                }
                            }
                            if (j==p.length){//如果到最后
                                index=t;
                                max=j-i;
                            }                    
                        }		
                        if(j==p.length&&flag==false){//如果找到最后，而且标识依然为FALSE，说明此时内存中的页号在未来都没有出现，则采用先进先出的方式替换
                            if(w==m){
                                w=0;
                            }
                            map.remove(w);
                            map.put(w,k);//修改表内元素
                            w++;
                        }else{//否则移除index最大的元素
                            map.remove(index);
                            map.put(index,k);//修改表内元素
                        }		
                    }
                    for(Map.Entry<Integer, Integer> entry:map.entrySet()){    
                        s=s+entry.getValue();    
                    }
                    if(hasQuickTablejCheckBox.isSelected()){
                        time = quickTableTime+memoryTime+missInterruptTime+memoryTime;
                        allTime = allTime +time;
                    }else{
                        time = memoryTime+missInterruptTime+memoryTime;
                        allTime = allTime +time;
                    }
                    try {
                        if(memoryTime!=-1&&missInterruptTime!=-1){
                            OPTjTextArea.append("内存页号：" + s + "；" + "时间：" + time + "us；缺页\r\n");
                            OPTjTextArea.setCaretPosition(OPTjTextArea.getText().length());  //让滚动条滚动
                        }else{
                            OPTjTextArea.append("驻留页号："+s+"us；缺页\r\n");
                            OPTjTextArea.setCaretPosition(OPTjTextArea.getText().length());  //让滚动条滚动
                        }
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    s="";
                    time=0;
                    flag=false;
                }else{
                    for(Map.Entry<Integer, Integer> entry:map.entrySet()){    
                        s=s+entry.getValue();    
                    }
                    if(hasQuickTablejCheckBox.isSelected()){
                        for(Integer x:quick){	
                            if(k==x){
                                time = quickTableTime+memoryTime;
                                allTime = allTime +time;
                                System.out.println("在快表命中");
                                break;
                            }else{
                                time = quickTableTime+memoryTime+memoryTime;
                                allTime = allTime +time;
                                quick.poll();
                                quick.offer(k);
                                break;
                            }
                        }
                    }else{
                        time=memoryTime + memoryTime;
                        allTime = allTime +time;
                    }
                    try {
                        if(memoryTime!=-1&&missInterruptTime!=-1){
                            OPTjTextArea.append("内存页号：" + s + "；" + "时间：" + time + "us；不缺页\r\n");
                            OPTjTextArea.setCaretPosition(OPTjTextArea.getText().length());  //让滚动条滚动
                        }else{
                            OPTjTextArea.append("驻留页号："+s+"us；不缺页\r\n");
                            OPTjTextArea.setCaretPosition(OPTjTextArea.getText().length());  //让滚动条滚动
                        }
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    s="";
                    time=0;
                }
            }
            NumberFormat formatter = new DecimalFormat("0.0");
            Double x=new Double((double)q/(double)p.length);
            String xx = formatter.format(x*100);
            OPTmissnumberjLabel.setText(q+"");
            OPTmissratejLabel.setText(xx+"%");
            OPTallmemorytimejLabel.setText(allTime+"us");
            startjButton.setEnabled(true);
            stopjButton.setEnabled(false);
            resumejButton.setEnabled(false);
            suspendjButton.setEnabled(false);
        }
    }
    
    
    //LRU算法
    class LRU implements Runnable{
        int p[],m,q=0,time=0,allTime=0;
        String miss = "";
        public synchronized void run(){
            Map<Integer,Integer>map=new HashMap<Integer,Integer>();
            List<Integer>list=new ArrayList<Integer>();
            Queue<Integer> quick = new LinkedList<Integer>();  //快表队列，快表均采用先进先出的置换方式.
            String s = "";
            p=paging;
            m=memoryCount;
            for (int i=0;i<p.length;i++){
                list.add(p[i]);
            }
            List<Integer>linkedlist=new LinkedList<Integer>();//栈
            for (int i=0;i<p.length;i++){
                int k=list.get(i);//从list取出每一个页号
                if (!map.containsKey(k)){
                    q++;//不能直接找到次数加1
                    if(hasQuickTablejCheckBox.isSelected()&&i<3){
                        quick.offer(k);     //初始元素加入快表队列,并设长度为3
                    }
                  //minpagenumber  maxpagenumber 最小最大页面号
                    if (map.size()<m){//如果没有装满
                        int temp=map.size();   
                        map.put(k,temp);   //map(7,0) map(0,1)  map(1,2)   map(k,temp)
                        linkedlist.add(k);//添加位置      7,0,1
                    }else{       //如果装满
                        int temp=linkedlist.get(0);  //temp=7
                        int c=map.get(temp);//位置       c=0   通过键值得到值
                        map.remove(temp);   // 除去键值为temp的一组map
                        map.put(k,c);      //  map(0,1)  map(1,2)  map(2,0)
                        linkedlist.remove(0);
                        linkedlist.add(k);   //0,1,2
                    }
                    if(hasQuickTablejCheckBox.isSelected()){
                        time = quickTableTime+memoryTime+missInterruptTime+memoryTime;
                        allTime = allTime +time;
                    }else{
                        time = memoryTime+missInterruptTime+memoryTime;
                        allTime = allTime +time;
                    }
                    miss = "缺页";
                }else{//如果包含这个值，把这个值拿走并在后面压入
                    int d=linkedlist.indexOf(k);//查找存在位置
                    linkedlist.remove(d);
                    linkedlist.add(k);
                    if(hasQuickTablejCheckBox.isSelected()){
                        for(Integer x:quick){   //更新快表
                            if(k==x){
                                time = quickTableTime+memoryTime;
                                allTime = allTime +time;
                                System.out.println("在快表中命中");
                                break;
                            }else{
                                time = quickTableTime+memoryTime+memoryTime;
                                allTime = allTime +time;
                                quick.poll();
                                quick.offer(k);
                                break;
                            }
                        }
                    }else{
                        time=memoryTime + memoryTime;
                        allTime = allTime +time;
                    }
                    miss = "不缺页";
                }
             
                	for(int n=0;n<m;n++)      //  改：
                		for(Map.Entry<Integer, Integer> entry:map.entrySet())
                		{
                			if(entry.getValue()==n)
                			{
                				s=s+entry.getKey();
                			}
                		}
                try {
                    if(memoryTime!=-1&&missInterruptTime!=-1){
                        LRUjTextArea.append("内存页号：" + s + "；" + "时间：" + time + "us；" + miss + "\r\n");
                        LRUjTextArea.setCaretPosition(LRUjTextArea.getText().length());  //让滚动条滚动
                    }else{
                        LRUjTextArea.append("内存页号：" + s + "；" + miss + "\r\n");
                        LRUjTextArea.setCaretPosition(LRUjTextArea.getText().length());  //让滚动条滚动
                    }
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                s="";
                time=0;
	    }
            NumberFormat formatter = new DecimalFormat("0.0");
            Double x=new Double((double)q/(double)p.length);
            String xx = formatter.format(x*100);
            LRUmissnumberjLabel.setText(q+"");
            LRUmissratejLabel.setText(xx+"%");
            LRUallmemorytimejLabel.setText(allTime+"us");
            startjButton.setEnabled(true);
            stopjButton.setEnabled(false);
            resumejButton.setEnabled(false);
            suspendjButton.setEnabled(false);
        }
    }
    
    
    //LFU算法
    class LFU implements Runnable{
        int p[];
        int q=0,min = 100,key=0,value=0,m;//初始变量
        int time=0,allTime=0;
        String miss="";
        public synchronized void run(){
            Map<Integer,Integer>map=new LinkedHashMap<Integer,Integer>();//之所以采用LinkedHashMap，是为了使元素按序put
            List<Integer>list=new ArrayList<Integer>();
            Queue<Integer> quick = new LinkedList<Integer>();  //快表队列，快表均采用先进先出的置换方式.
            String s = "";
            p=paging;
            m=memoryCount;
            for (int i=0;i<p.length;i++){
                list.add(p[i]);
            }
            for(int i=0;i<p.length;i++){
                int k=list.get(i);//从list取出每一个页号
                if(!map.containsKey(k)){
                    q++;
                    if(hasQuickTablejCheckBox.isSelected()&&i<3){
                        quick.offer(k);     //初始元素加入快表队列,并设长度为3
                    }
                    if(map.size()<m){         
                        map.put(k,1);	//添加元素，置访问次数为1   map(7,1) map(0,1)  map(1,1)
                    }else{
                        for(Map.Entry<Integer, Integer> entry:map.entrySet()){ //替换访问次数最少的那个
                        	System.out.print(entry.getKey());
                            if(min>entry.getValue()){
                                min = entry.getValue();
                                key=entry.getKey();
                            }
                            
                        } 
                        System.out.print("\t");
                        map.remove(key);    //更新数据
                        map.put(k, 1);//新加入元素，并置访问次数为1
                    }
                    if(hasQuickTablejCheckBox.isSelected()){
                        time = quickTableTime+memoryTime+missInterruptTime+memoryTime;
                        allTime = allTime +time;
                    }else{
                        time = memoryTime+missInterruptTime+memoryTime;
                        allTime = allTime +time;
                    }		
                    min=100;
                    miss="缺页";
                }else{ //如果在map中，访问次数++
                    for(Map.Entry<Integer, Integer> entry:map.entrySet()){    
                        if(k==entry.getKey()){
                            value = entry.getValue();
                            entry.setValue(++value);   //值加1  
                        } 
                    } 
                    if(hasQuickTablejCheckBox.isSelected()){
                        for(Integer x:quick){	
                            if(k==x){
                                time = quickTableTime+memoryTime;
                                allTime = allTime +time;
                                System.out.println("在快表中命中");
                                break;
                            }else{
                                time = quickTableTime+memoryTime+memoryTime;
                                allTime = allTime +time;
                                quick.poll();
                                quick.offer(k);
                                break;
                            }
                        }
                    }else{
                        time=memoryTime+memoryTime;
                        allTime = allTime +time;
                    }
                    miss="不缺页";
                }
                for(Map.Entry<Integer, Integer> entry:map.entrySet()){    
                    s=s+entry.getKey();    
                }
                try {
                    if(memoryTime!=-1&&missInterruptTime!=-1){
                        LFUjTextArea.append("内存页号：" + s + "；"+"时间：" + time + "us；" + miss +"\r\n");
                        LFUjTextArea.setCaretPosition(LFUjTextArea.getText().length());  //让滚动条滚动
                    }else{
                        LFUjTextArea.append("内存页号：" + s + "；" + miss + "\r\n");
                        LFUjTextArea.setCaretPosition(LFUjTextArea.getText().length());  //让滚动条滚动
                    }
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                s="";
                time=0;
            }
            NumberFormat formatter = new DecimalFormat("0.0");
            Double x=new Double((double)q/(double)p.length);
            String xx = formatter.format(x*100);
            LFUmissnumberjLabel.setText(q+"");
            LFUmissratejLabel.setText(xx+"%");
            LFUallmemorytimejLabel.setText(allTime+"us");
            startjButton.setEnabled(true);
            stopjButton.setEnabled(false);
            resumejButton.setEnabled(false);
            suspendjButton.setEnabled(false);
        }
    }
    
    //帮助页
    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        jDialog1.setVisible(true);
        jDialog1.setLocationRelativeTo(jTabbedPane1);//对话框居中
    }//GEN-LAST:event_jMenuItem2ActionPerformed
    
    //继续线程
    private void resumejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resumejButtonActionPerformed
        FIFOThread.resume();
        LRUThread.resume();
        OPTThread.resume();
        LFUThread.resume();
        resumejButton.setEnabled(false);
        suspendjButton.setEnabled(true);
    }//GEN-LAST:event_resumejButtonActionPerformed
    
    //暂停线程
    private void suspendjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_suspendjButtonActionPerformed
        FIFOThread.suspend();
        LRUThread.suspend();
        OPTThread.suspend();
        LFUThread.suspend();
        resumejButton.setEnabled(true);
        suspendjButton.setEnabled(false);
    }//GEN-LAST:event_suspendjButtonActionPerformed
    
    //保存数据
    private void savejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savejButtonActionPerformed
        jFileChooser1.showSaveDialog(showjPanel);  //保存文件
        String path = jFileChooser1.getCurrentDirectory().getPath();//获得保存路径
        String documentname;
        if(jFileChooser1.getSelectedFile()!=null){//获得保存文件名，如果没有，默认为test
            documentname = jFileChooser1.getSelectedFile().getName();
        }else{
            documentname = "test";
        }
        path = path+"\\"+documentname+".txt";//拼接成完整路径
        String isOrNotQuick;
        if(hasQuickTablejCheckBox.isSelected()){
            isOrNotQuick = "已启用快表";
        }else{
            isOrNotQuick = "未启用快表";
        }
        try{
            FileUtils.write(new File(path), "1.参数设置："+"\r\n" + "驻留页面的内存数：" + memoryCount + "\r\n" + "页面总个数：" + pageCountjTextField.getText() + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), "页号序列:" + pagingjTextField.getText() + "\r\n"+"内存存取时间：" + memoryTimejTextField.getText() + "\r\n" + "缺页中断时间：" + missInterruptTimejTextField.getText() + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), "是否启用快表：" + isOrNotQuick + "\r\n"+ "访问快表时间：" + quickTableTimejTextField.getText() + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), "2.FIFO模拟过程：" + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), FIFOjTextArea.getText(),"UTF-8",true);
            FileUtils.write(new File(path), "缺页中断次数：" + FIFOmissnumberjLabel.getText() + "\r\n" + "缺页率：" + FIFOmissratejLabel.getText() + "\r\n" + "内存总存取时间：" + FIFOallmemorytimejLabel.getText() + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), "3.LRU模拟过程：" + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), LRUjTextArea.getText(),"UTF-8",true);
            FileUtils.write(new File(path), "缺页中断次数:" + LRUmissnumberjLabel.getText() + "\r\n" + "缺页率：" + LRUmissratejLabel.getText() + "\r\n" + "内存总存取时间：" + LRUallmemorytimejLabel.getText() + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), "4.OPT模拟过程：" + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), OPTjTextArea.getText(),"UTF-8",true);
            FileUtils.write(new File(path), "缺页中断次数:" + OPTmissnumberjLabel.getText() + "\r\n" + "缺页率：" + OPTmissratejLabel.getText() + "\r\n" + "内存总存取时间：" + OPTallmemorytimejLabel.getText() + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), "5.LFU模拟过程：" + "\r\n","UTF-8",true);
            FileUtils.write(new File(path), LFUjTextArea.getText(),"UTF-8",true);
            FileUtils.write(new File(path), "缺页中断次数:" + LFUmissnumberjLabel.getText() + "\r\n" + "缺页率：" + LFUmissratejLabel.getText() + "\r\n" + "内存总存取时间：" + LFUallmemorytimejLabel.getText() + "\r\n","UTF-8",true);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_savejButtonActionPerformed
    
    //清空按钮
    private void clearjButtonjButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearjButtonjButton5ActionPerformed
        clearTextArea();
    }//GEN-LAST:event_clearjButtonjButton5ActionPerformed
    
    //停止算法线程
    private void stopjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopjButtonActionPerformed
        FIFOThread.stop();
        LRUThread.stop();
        OPTThread.stop();
        LFUThread.stop();
        startjButton.setEnabled(true);
        stopjButton.setEnabled(false);
    }//GEN-LAST:event_stopjButtonActionPerformed
    
    //模拟过程开始
    private void startjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startjButtonActionPerformed
        clearTextArea();
        FIFO fifo = new FIFO();
        FIFOThread = new Thread(fifo);
        LRU lru = new LRU();
        LRUThread = new Thread(lru);
        OPT opt = new OPT();
        OPTThread = new Thread(opt);
        LFU lfu = new LFU();
        LFUThread = new Thread(lfu);
        
        getParameters();
        FIFOThread.start();
        LRUThread.start();
        OPTThread.start();
        LFUThread.start();
        startjButton.setEnabled(false);
        stopjButton.setEnabled(true);
        suspendjButton.setEnabled(true);
        savejButton.setEnabled(true);
    }//GEN-LAST:event_startjButtonActionPerformed
    
    //设置是否启用快表
    private void hasQuickTablejCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hasQuickTablejCheckBoxActionPerformed
        if(hasQuickTablejCheckBox.isSelected()){
            quickTableTimejTextField.setEnabled(true);
        }else{
            quickTableTimejTextField.setEnabled(false);
        }
    }//GEN-LAST:event_hasQuickTablejCheckBoxActionPerformed
    
    //产生随机页面序列
    private void RandomjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RandomjButtonActionPerformed
        int maxpagenumber = Integer.parseInt(maxPageNumberjSpinner.getValue().toString());
        int minpagenumber = Integer.parseInt(minPageNumberjSpinner.getValue().toString());
        int pagecount = Integer.parseInt(pageCountjTextField.getText());
        
        int pagelist[] = new int[pagecount];
        String pagingstr="";
        for(int i=0;i<pagecount;i++){//循环生成随机页面序列
            pagelist[i] = new Random().nextInt(maxpagenumber-minpagenumber) + minpagenumber;
            if(i == pagecount - 1){//最后没有分号
                pagingstr = pagingstr + pagelist[i];
            }
            else{
                pagingstr = pagingstr+ pagelist[i] + ",";
            }
        }
        pagingjTextField.setText(pagingstr);  //将随机序列放入文本框中
    }//GEN-LAST:event_RandomjButtonActionPerformed
    
    //恢复默认值按钮
    private void ResetjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResetjButtonActionPerformed
        memoryCountjTextField.setText("3");
        pageCountjTextField.setText("20");
        minPageNumberjSpinner.setValue(0);
        maxPageNumberjSpinner.setValue(9);
        memoryTimejTextField.setText("8");
        missInterruptTimejTextField.setText("20");
        hasQuickTablejCheckBox.setSelected(true);
        quickTableTimejTextField.setEnabled(true);
        quickTableTimejTextField.setText("1");
        pagingjTextField.setText("7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1");
    }//GEN-LAST:event_ResetjButtonActionPerformed
    
    //确定按钮进行验证输入是否合法
    private void surejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_surejButtonActionPerformed
        //输入必须是数字
        if(!isNumber(memoryCountjTextField.getText())||!isNumber(pageCountjTextField.getText())||!isNumber(memoryTimejTextField.getText())||!isNumber(missInterruptTimejTextField.getText())||!isNumber(quickTableTimejTextField.getText())){
            jDialog2.setVisible(true);
            jDialog2.setLocationRelativeTo(jTabbedPane1);//对话框居中
        }
        if(Integer.parseInt(pageCountjTextField.getText())!=(pagingjTextField.getText().split(",").length)){
            jDialog3.setVisible(true);
            jDialog3.setLocationRelativeTo(jTabbedPane1);//对话框居中
        }
        else{
            startjButton.setEnabled(true);
            clearjButton.setEnabled(true);
        }
    }//GEN-LAST:event_surejButtonActionPerformed

    private void ok2jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok2jButton1ActionPerformed
        jDialog3.dispose();
    }//GEN-LAST:event_ok2jButton1ActionPerformed

    private void ok1jButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok1jButtonActionPerformed
        jDialog2.dispose();
    }//GEN-LAST:event_ok1jButtonActionPerformed
    
    //初始化并获得缺省值或者获得表单输入值
    public void getParameters(){
        String splitPage[]=null;
        if(pageCountjTextField!=null&&!"".equals(pageCountjTextField.getText())&&!"".equals(pageCountjTextField.getText())&&pageCountjTextField!=null){//页面总个数
            pageCount=Integer.parseInt(pageCountjTextField.getText());
        }else{
            pageCount=20;
        }
        if(memoryCountjTextField!=null&&!"".equals(memoryCountjTextField.getText())&&!"".equals(memoryCountjTextField.getText())&&memoryCountjTextField!=null){//内存个数
            memoryCount = Integer.parseInt(memoryCountjTextField.getText());
        }else{
            memoryCount = 3;
        }
        if(pagingjTextField!=null&&!"".equals(pagingjTextField.getText())&&!"".equals(pagingjTextField.getText())&&pagingjTextField!=null){//页面序列号
            splitPage = pagingjTextField.getText().split(",");
        }else{
            splitPage = "7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1".split(",");
        }
        
        if(memoryTimejTextField!=null&&memoryTimejTextField.getText()!=null&&!"".equals(memoryTimejTextField.getText())){//内存存取时间
            memoryTime=Integer.parseInt(memoryTimejTextField.getText());
        }else{
            memoryTime=-1;
        }
        if(missInterruptTimejTextField!=null&&missInterruptTimejTextField.getText()!=null&&!"".equals(missInterruptTimejTextField.getText())){//缺页中断时间，将页号送至快表和内存
            missInterruptTime=Integer.parseInt(missInterruptTimejTextField.getText());
        }else{
            missInterruptTime=-1;
        }
        if(quickTableTimejTextField!=null&&quickTableTimejTextField.getText()!=null&&!"".equals(quickTableTimejTextField.getText())){//访问快表时间
            quickTableTime=Integer.parseInt(quickTableTimejTextField.getText());
        }else{
            quickTableTime=-1;
        }
        
        paging=new int[pageCount];
        for(int i=0;i<splitPage.length;i++){
            paging[i] = Integer.parseInt(splitPage[i]);
        }
    }
    
    //判断输入是否为数字
    public boolean isNumber(String str){
        Pattern pattern = Pattern.compile("[0-9]*");//匹配模式
        Matcher isNumberOrNot = pattern.matcher(str);
        if( !isNumberOrNot.matches() ){
            return false; 
        }
        return true; 
    }
    
    //清空文本框
    public void clearTextArea(){
        FIFOjTextArea.setText("");
        LRUjTextArea.setText("");
        OPTjTextArea.setText("");
        LFUjTextArea.setText("");
        FIFOmissnumberjLabel.setText("0");
        LRUmissnumberjLabel.setText("0");
        OPTmissnumberjLabel.setText("0");
        LFUmissnumberjLabel.setText("0");
        FIFOmissratejLabel.setText("0");
        LRUmissratejLabel.setText("0");
        OPTmissratejLabel.setText("0");
        LFUmissratejLabel.setText("0");
        FIFOallmemorytimejLabel.setText("0");
        LRUallmemorytimejLabel.setText("0");
        OPTallmemorytimejLabel.setText("0");
        LFUallmemorytimejLabel.setText("0");
    }
    
    /**
     * @param args the command line arguments
     */
    
    //总开始程序
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Windows".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel FIFOallmemorytimejLabel;
    private javax.swing.JPanel FIFOjPanel;
    private javax.swing.JScrollPane FIFOjScrollPane;
    private javax.swing.JTextArea FIFOjTextArea;
    private javax.swing.JLabel FIFOmissnumberjLabel;
    private javax.swing.JLabel FIFOmissratejLabel;
    private javax.swing.JLabel LFUallmemorytimejLabel;
    private javax.swing.JPanel LFUjPanel;
    private javax.swing.JScrollPane LFUjScrollPane;
    private javax.swing.JTextArea LFUjTextArea;
    private javax.swing.JLabel LFUmissnumberjLabel;
    private javax.swing.JLabel LFUmissratejLabel;
    private javax.swing.JLabel LRUallmemorytimejLabel;
    private javax.swing.JPanel LRUjPanel;
    private javax.swing.JScrollPane LRUjScrollPane;
    private javax.swing.JTextArea LRUjTextArea;
    private javax.swing.JLabel LRUmissnumberjLabel;
    private javax.swing.JLabel LRUmissratejLabel;
    private javax.swing.JLabel OPTallmemorytimejLabel;
    private javax.swing.JPanel OPTjPanel;
    private javax.swing.JScrollPane OPTjScrollPane;
    private javax.swing.JTextArea OPTjTextArea;
    private javax.swing.JLabel OPTmissnumberjLabel;
    private javax.swing.JLabel OPTmissratejLabel;
    private javax.swing.JButton RandomjButton;
    private javax.swing.JButton ResetjButton;
    private javax.swing.JPanel basicjPanel;
    private javax.swing.JButton clearjButton;
    private javax.swing.JCheckBox hasQuickTablejCheckBox;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JDialog jDialog2;
    private javax.swing.JDialog jDialog3;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JSpinner maxPageNumberjSpinner;
    private javax.swing.JTextField memoryCountjTextField;
    private javax.swing.JTextField memoryTimejTextField;
    private javax.swing.JSpinner minPageNumberjSpinner;
    private javax.swing.JTextField missInterruptTimejTextField;
    private javax.swing.JButton ok1jButton;
    private javax.swing.JButton ok2jButton1;
    private javax.swing.JTextField pageCountjTextField;
    private javax.swing.JPanel pagequeuejPanel;
    private javax.swing.JTextField pagingjTextField;
    private javax.swing.JTextField quickTableTimejTextField;
    private javax.swing.JPanel resultjPanel;
    private javax.swing.JButton resumejButton;
    private javax.swing.JButton savejButton;
    private javax.swing.JPanel setParameterjPanel;
    private javax.swing.JPanel showjPanel;
    private javax.swing.JButton startjButton;
    private javax.swing.JButton stopjButton;
    private javax.swing.JButton surejButton;
    private javax.swing.JButton suspendjButton;
    private javax.swing.JPanel timejPanel;
    // End of variables declaration//GEN-END:variables
}
